package com.gla.dao;

import com.gla.entity.Shop;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShopMapper {
    @Select("SELECT * FROM SHOP WHERE isdel < 1")
    List<Shop> selectAllShop();

    @Select("SELECT * FROM SHOP WHERE id = #{id} AND isdel < 1")
    Shop selectShopById(Integer id);

    @Update("UPDATE SHOP SET isdel = 1 WHERE id = #{id}")
    void delShopById(Integer id);

    @Update("UPDATE SHOP SET name = #{name}, address = #{address}, longitude = #{longitude}, latitude = #{latitude}, photo = #{photo}, introduction = #{introduction} WHERE id = #{id}")
    void updateShopById(Integer id, String name, String address, Float longitude, Float latitude, String photo, String introduction);

    @Insert("INSERT INTO SHOP (name, address, longitude, latitude, photo, introduction, isdel) VALUES (#{name}, #{address}, #{longitude}, #{latitude}, #{photo}, #{introduction}, 0)")
    void insertShop(String name, String address, Float longitude, Float latitude, String photo, String introduction);
}
